package zcjq.d909;

import java.util.*;

public class P1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int[] params = Arrays.stream(scanner.nextLine().trim().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
        int N = params[0];  //节点数量
        int M = params[1];  //涂色数量
        int K = params[2];  //根节点编号

        //涂色节点
        List<Integer> coloredList = new ArrayList<>();
        Arrays.stream(scanner.nextLine().trim().split(" ")).mapToInt(s -> Integer.parseInt(s)).forEach(s -> {
            coloredList.add(s);
        });

        Map<Integer, List<Integer>> map = new HashMap<>();
        for (int i = 1; i < N; i++) {
            int[] row = Arrays.stream(scanner.nextLine().trim().split(" ")).mapToInt(s -> Integer.parseInt(s)).toArray();
            if (!map.containsKey(row[0])) {
                map.put(row[0], new ArrayList<>());
            }
            map.get(row[0]).add(row[1]);
        }
        int[] minDistance = new int[]{Integer.MAX_VALUE};
        postScan(map, K, new ArrayList<>(), coloredList, minDistance);
        System.out.println(minDistance[0]);

    }

    private static List<Integer> postScan(Map<Integer, List<Integer>> treeMap, int nodeId, List<Integer> distanceList, List<Integer> coloredList, int[] minDistance) {
        if (!treeMap.containsKey(nodeId)) {//叶子节点
            if (coloredList.contains(nodeId)) {
                List<Integer> dis = new ArrayList<>();
                dis.add(1);
                return dis;
            }
            return new ArrayList<>(0);
        } else {//非叶子节点
            List<Integer> totalDis = new ArrayList<>();
            List<Integer> childs = treeMap.get(nodeId);
            for (int child : childs) {
                List<Integer> disList = postScan(treeMap, child, distanceList, coloredList, minDistance);
                if (disList.size() > 0) {
                    totalDis.addAll(disList);
                }
            }
            //
            if (coloredList.contains(nodeId)) {//当前节点为有色节点
                for (int dis : totalDis) {
                    if (minDistance[0] > dis) {
                        minDistance[0] = dis;
                    }
                }
                totalDis.clear();
                totalDis.add(nodeId);
            } else {
                for (int i = 0; i < totalDis.size(); i++) {
                    totalDis.set(i, totalDis.get(i) + 1);
                }
            }
            return totalDis;
        }
    }

}
